<template>
  <!-- 流动党员信息 -->
  <base-breadcrumb class="flexMemberInfo-container">
    <searchData
      :search-data="searchArr"
      @search="handleSearch"
    />
    <a-card :bordered="false">
      <!-- <title-name title="流动党员信息列表" /> -->
      <div
        class="pub-table-select-count"
        style="margin: 10px 0"
      >
        <a-icon
          type="info-circle"
          theme="twoTone"
        />
        <span>
          共计：
          <a>{{ totalInfo.totalNum || 0 }} 个</a>
        </span>
      </div>
      <list-table
        ref="table"
        row-key="id"
        :columns="columns"
        :request="loadData"
        :isScrollX="false"
        show-size-changer
        show-quick-jumper
        show-pagination="auto"
      >
        <template
          slot="action"
          slot-scope="text, record"
        >
          <div class="pub-table-list-action">
            <span
              v-btnPermission="'pa_006_shi_01'"
              @click="handleUpdate(record, 'turnIn')"
            >对内转入</span>
          </div>
        </template>
      </list-table>
    </a-card>
    <TurnInMember
      :visible.sync="visibleState.isTurnIn"
      :init-data="childInitData"
      @ok="handleTurnInFinish"
    />
  </base-breadcrumb>
</template>

<script>
import TurnInMember from './TurnInMember.vue'
import { STable } from '@/components' // 表格
import { getPartyMemberList } from '@/api/partyMasses/partyManage/partyMember.js'

const searchArr = [
  {
    name: '党员名称',
    value: 'partyMemberName',
    type: 'input',
  },
  {
    name: '党支部',
    value: 'partyOrgName',
    type: 'input',
  },
]
const columns = [
  {
    title: '序号',
    width: 80,
    dataIndex: 'index',
    customRender() {
      return arguments[2] + 1
    },
  },
  {
    title: '党员名称',
    dataIndex: 'partyMemberName',
  },
  {
    title: '之前所在党支部',
    dataIndex: 'partyOrgName',
  },
  {
    title: '党支部撤销时间',
    dataIndex: 'undoTime',
  },
  {
    title: '员工编号',
    dataIndex: 'employeeNum',
  },
  {
    title: '手机号码',
    dataIndex: 'phone',
  },
  {
    title: '当前岗位',
    dataIndex: 'currentPost',
    ellipsis: true,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '180px',
    align: 'center',
    scopedSlots: { customRender: 'action' },
  },
]
export default {
  name:'a'+ Date.now(),
  components: {
    STable,
    TurnInMember,
  },
  data() {
    return {
      totalInfo: {
        totalNum: 0,
      },
      visibleState: {
        isTurnIn: false,
      },
      childInitData: {}, // 传入子组件的数据
      searchArr,
      columns: columns,
      queryParam: {},
      exportFileName: '',
    }
  },
  methods: {
    handleTurnInFinish() {
      this.visibleState.isTurnIn = false
      this.refreshTable(false)
    },
    /**
     * 处理数据的相关操作（增删改查）
     */
    handleUpdate(data, pageType) {
      const actionMap = {
        turnIn: () => {
          this.childInitData = { ...data }
          this.visibleState.isTurnIn = true
        },
      }
      actionMap[pageType] && actionMap[pageType]()
    },
    handleSearch(val = {}) {
      this.queryParam = {
        ...val,
      }
      this.refreshTable()
    },
    refreshTable(flag = true) {
      this.$refs.table.refresh(flag)
    },
    async loadData(parameter) {
      // (1：流动党员/2：对内转出/3：对外转出)
      const requestParameters = Object.assign({}, { ...parameter }, { query: { ...this.queryParam, recordType: 1 } })
      return getPartyMemberList(requestParameters).then((res) => {
        this.totalInfo.totalNum = res.totalSize
        return {
          code:200,
          data: res.data,
          currentPage: res.currentPage,
          totalSize: res.totalSize,
        }
      })
    },
  },
}
</script>

<style>
</style>